import axios from 'axios'
axios.defaults.baseURL = ''
function http(params){
    return axios({...params}).then(res=>res.data).catch(err=>err);
}

//封装网络请求可以同时单次或者多次请求
async function network(params){
    //判断是否是多次并求
    if(params instanceof Array){
        //定义数组保存返回值
        let results = [];
        for(let index in params){
            let result = await http(params[index]);
            results.push(result);
        }
        return results
    }else{
        return await http(params);
    }
}

export default network;